package org.spiderflow.logs.entity;

import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import org.spiderflow.users.entity.Users;
import org.spiderflow.utils.DataUtil;
import org.spiderflow.utils.IpUtils;

import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;

/**
 * Created by Nicky.Tang on 2020/4/4 10:52 PM
 *
 * @since 02.12.10
 */
@Data
@TableName(value = "sp_logs")
public class Logs implements Serializable {

    private static final long serialVersionUID = 1L;

    private Integer logsId;
    private Integer logsType;
    private String ip;

    private String remarks;

    private Integer createId;

    private String createName;

    private String createTime;

    public Logs(){

    }

    /**
     * 初始化用户信息
     * @param users
     * @param request
     */
    public Logs(Users users, HttpServletRequest request) {
        this.setIp(IpUtils.getIpAddr(request));
        this.setCreateId(users.getUserId());
        this.setCreateName(users.getUserPhone());
        this.setCreateTime(DataUtil.getNow());
    }

    public static class Constant {
        public static class LogsType {
            //            private static Integer register=10001;
            public static final Integer loggin = 10001;
            public static final Integer logout = 10002;
            public static final Integer updateUser = 10003;
        }
    }


}